package com.dzm.thirdpart.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 作者：Dzm
 * 时间：2024-09-14-10:57
 * 功能：
 */

@Controller
@RequestMapping
public class ThirdpartController {

    @GetMapping({"/login", "/login.html"})
    public String login(@RequestParam("redirectUrl") String redirectUrl) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        if(attributes != null) {
            HttpServletRequest request = attributes.getRequest();
            HttpSession session = request.getSession();
            session.setAttribute("redirectUrl", redirectUrl);
        }

        return "login";
    }

}
